home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / MotifApp / ch2 / Stopwatch2 / Stopwatch.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-03  |  2.4 KB  |  90 lines

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //////////////////////////////////////////////////////////////////////////////
  3. //         This example code is from the book:
  4. //
  5. //           Object-Oriented Programming with C++ and OSF/Motif
  6. //         by
  7. //           Douglas Young
  8. //           Prentice Hall, 1992
  9. //           ISBN 0-13-630252-1    
  10. //
  11. //         Copyright 1991 by Prentice Hall
  12. //         All Rights Reserved
  13. //
  14. //  Permission to use, copy, modify, and distribute this software for 
  15. //  any purpose except publication and without fee is hereby granted, provided 
  16. //  that the above copyright notice appear in all copies of the software.
  17. ///////////////////////////////////////////////////////////////////////////////
  18. //////////////////////////////////////////////////////////////////////////////
  19.  
  20.  
  21. ////////////////////////////////////////////////////////////////
  22. // StopWatch.C: Group subcomponents into one stopwatch component
  23. //              Customizable, UIComponent version
  24. /////////////////////////////////////////////////////////////////
  25. #include "Stopwatch.h"
  26. #include <Xm/Xm.h>
  27. #include <Xm/RowColumn.h>
  28. #include "Timer.h"
  29. #include "Face.h"
  30. #include "Control.h"
  31.   
  32. XtResource Stopwatch::_resources [] = {
  33. {
  34.      "interval", 
  35.      "Interval", 
  36.      XmRInt, 
  37.      sizeof ( int ),
  38.      XtOffset ( Stopwatch *, _interval ), 
  39.      XmRString, 
  40.      (XtPointer) "1000",
  41.   },
  42. };
  43.   
  44. Stopwatch::Stopwatch ( Widget  parent, 
  45.                          char   *name ) : UIComponent ( name )
  46.   {
  47.       // Create a manager widget to hold all components
  48.   
  49.       _w = XmCreateRowColumn ( parent, _name, NULL, 0 );
  50.   
  51.       // Call UIComponent hook to set up destruction handler
  52.   
  53.        installDestroyHandler();
  54.   
  55.       // Retrieve customizable parameters for this class
  56.   
  57.       getResources ( _resources, XtNumber ( _resources ) );
  58.   
  59.       // Instantiate the three sub-components of the stopwatch
  60.   
  61.       _face = new  Face ( _w, "face" );
  62.       _timer = new Timer ( XtWidgetToApplicationContext ( parent ), 
  63.                            _face, 
  64.                            _interval );
  65.       _control = new Control ( _w, "control", this, _timer );
  66.   
  67.       // Manage the two user interface components
  68.   
  69.       _face->manage();
  70.       _control->manage();
  71.   }
  72.  
  73. Stopwatch::~Stopwatch ( )
  74. {
  75.     delete _face;
  76.     delete _timer;
  77.     delete _control;
  78. }
  79.  
  80. void Stopwatch::timerStarted()
  81. {
  82.     // Empty
  83. }
  84.  
  85. void Stopwatch::timerStopped()
  86. {
  87.     // Empty
  88. }
  89.  
  90.